package com.pkx.cloud.fse7.dms.site.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.dms.site.entity.DoorDeviceSite;
import com.pkx.cloud.fse7.dms.site.service.DoorDeviceSiteService;
import com.pkx.cloud.whzx.comn.ORpose;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制器
 *
 * @author chenwg
 * @since 2020-12-23
 */
@RestController
@RequestMapping("/site/door-device-site")
@Api(value = "读头定位", tags = "读头定位")
@Slf4j
@ORpose
public class DoorDeviceSiteController {

    @Autowired
    private DoorDeviceSiteService doorDeviceSiteService;

    @ApiOperation("分页列表")
    @GetMapping("/page")
    public Page<DoorDeviceSite> page(Page page, DoorDeviceSite doorDeviceSite) {
        return doorDeviceSiteService.pageList(page, doorDeviceSite);
    }

    @ApiOperation("列表")
    @GetMapping("/list")
    public List<DoorDeviceSite> list(DoorDeviceSite doorDeviceSite) {
        return doorDeviceSiteService.listByEntity(doorDeviceSite);
    }

    @ApiOperation("详情")
    @GetMapping(value = "/{id}")
    public DoorDeviceSite selectById(@PathVariable("id") String id) {
        return doorDeviceSiteService.selectById(id);
    }

    @ApiOperation("新增")
    @PostMapping("/")
    public Boolean add(@RequestBody DoorDeviceSite doorDeviceSite) {
        return doorDeviceSiteService.saveDoorDeviceSite(doorDeviceSite);
    }

    @ApiOperation("修改")
    @PutMapping("/")
    public Boolean modify(@RequestBody DoorDeviceSite doorDeviceSite) {
        return doorDeviceSiteService.modify(doorDeviceSite);
    }

    @ApiOperation("读头定位")
    @PutMapping("/update")
    public Boolean update(@RequestBody DoorDeviceSite doorDeviceSite) {
        return doorDeviceSiteService.saveOrUpdate(doorDeviceSite);
    }

    @ApiOperation("删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    public Boolean deleteById(@PathVariable("id") String id) {
        return doorDeviceSiteService.deleteById(id);
    }
}
